package com.myplans.client.view.custom;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class SignUpDialogBox extends Composite implements HasText {

	private static SignUpDialogBoxUiBinder uiBinder = GWT
			.create(SignUpDialogBoxUiBinder.class);

	interface SignUpDialogBoxUiBinder extends UiBinder<Widget, SignUpDialogBox> {
	}

	public SignUpDialogBox() {
		initWidget(uiBinder.createAndBindUi(this));
		dialogBox.hide();
	}

	@UiField
	Button button;
	@UiField
	DialogBox dialogBox;
	@UiField
	TextBox email;
	@UiField
	PasswordTextBox password;
	@UiField
	Button signUpButton;
	@UiField
	TextBox name;

	public SignUpDialogBox(String firstName) {
		initWidget(uiBinder.createAndBindUi(this));
		button.setText(firstName);
	}

	@UiHandler("button")
	void onClick(ClickEvent e) {
		dialogBox.hide();
	}

	public void setText(String text) {
		button.setText(text);
	}

	public String getText() {
		return button.getText();
	}
	
	public void show() {
		dialogBox.center();
	}

	public TextBox getEmail() {
		return email;
	}

	public PasswordTextBox getPassword() {
		return password;
	}

	public Button getSignUpButton() {
		return signUpButton;
	}

	public TextBox getName() {
		return name;
	}
	
	public DialogBox getDialogBox() {
		return dialogBox;
	}

}
